/*
    SUSAN® - Sole of Unix Save ANything

   Copyright (C) 2008-2008 Hechzh Property
   Copyright (C) 2016-2020 Hechzh Property

   
*/
/*
 * Kern Sibbald, March MMVII
 */
/**
 * @file
 * Status packet definition that is used in both the SD and FD. It
 * permits Win32 to call OutputStatus() and get the output back
 * at the callback address line by line, and for Linux code,
 * the output can be sent directly to a BareosSocket.
 */

#ifndef BAREOS_LIB_STATUS_PACKET_H_
#define BAREOS_LIB_STATUS_PACKET_H_

#include <include/bareos.h>
#include <string>

class BareosSocket;

/**
 * Packet to send to OutputStatus()
 */
class StatusPacket {
 public:
  StatusPacket() = default;

  virtual ~StatusPacket() = default;
  BareosSocket* bs = nullptr; /* used on Unix machines */
  void* context = nullptr;    /* Win32 */
  void (*callback)(const char* msg,
                   int len,
                   void* context) = nullptr; /* Win32 */
  bool api = false;                          /* set if we want API output */
  void send(const char* msg, int len);
  void send(PoolMem& msg, int len) { send(msg.c_str(), len); }
  void send(const std::string& msg) { send(msg.c_str(), msg.length()); }
};
#endif
